<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>使用xampp和wordpress搭建个人博客 | chilono!</title><script src="https://cdn.bootcss.com/valine/1.4.4/Valine.min.js"></script><link rel="stylesheet" href="/css/arknights.css"><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/highlight.js/10.1.2/styles/atom-one-dark-reasonable.min.css"><style>@font-face {
 font-family: BenderLight;
 src: local('Bender'), url("/font/BenderLight.ttf");
}
@font-face {
 font-family: 'JetBrains Mono';
 src: local('JetBrains Mono'), url('/font/JetBrainsMono-Regular.woff2') format('woff2');
}</style><meta name="generator" content="Hexo 5.0.2"></head><body><header><nav><a href="/">Home</a><a href="/archives/">Archives</a><a href="/about/">About</a></nav></header><main><article><div id="post-bg"><div id="post-title"><div id="post-info"><span>date:<time datetime="2019-03-09T09:43:10.000Z" id="date"> 2019-03-09</time></span><br><span>updated:<time datetime="2020-08-22T13:28:47.733Z" id="updated"> 2020-08-22</time></span></div><h1>使用xampp和wordpress搭建个人博客</h1><hr></div><div id="post-content"><p>早期记录的搭建wordpress的文章，虽然现在不用wordpress，但总归是自己的记录，收一下好了。<br>记录一下搭建博客的过程，以及各种配置。好记性不如烂笔头。</p>
<h1 id="开始准备"><a href="#开始准备" class="headerlink" title="开始准备"></a>开始准备</h1><ul>
<li>一台linux服务器</li>
<li>SSH客户端软件</li>
</ul>
<p>个人使用的是arch，至于linux的安装，可以参考这篇：<a target="_blank" rel="noopener" href="https://wiki.archlinux.org/index.php/Installation_guide">ArchLinux的安装</a></p>
<h1 id="XAMPP"><a href="#XAMPP" class="headerlink" title="XAMPP"></a>XAMPP</h1><p>下载地址：<a target="_blank" rel="noopener" href="https://www.apachefriends.org/download.html">XAMPP</a></p>
<p>以各种方式获取XAMPP到服务器上后，可以开始我们的安装了。</p>
<h2 id="安装xampp"><a href="#安装xampp" class="headerlink" title="安装xampp"></a>安装xampp</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> ./xampp-&lt;具体版本号与平台信息&gt;.run</span><br></code></pre></td></tr></table></figure>

<p>注意：需要管理员权限</p>
<p>XAMPP会给予几个选项让你进行选择，但基本不需要变动，全部默认等待安装即可</p>
<h2 id="apache虚拟主机"><a href="#apache虚拟主机" class="headerlink" title="apache虚拟主机"></a>apache虚拟主机</h2><p>apache的虚拟主机配置文件没包括，习惯用虚拟主机了，具体好处倒不是很清楚，不过可以随时扩展站点是个很棒的好处</p>
<p>找到xampp中apache的配置文件，如果没有进行修改安装位置的话，默认在这个位置：<code>/opt/lampp/etc/httpd.conf</code></p>
<p>找到这一行将行首的’#’删除，取消注释</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash">Include etc/extra/httpd-vhosts.conf</span><br></code></pre></td></tr></table></figure>

<p>之后开始编辑虚拟主机配置文件：<code>/opt/lampp/etc/extra/httpd-vhosts.conf</code></p>
<p>填入如下配置，一个最简陋的虚拟主机就出来了</p>
<figure class="highlight accesslog"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs accesslog">&lt;VirtualHost *:<span class="hljs-number">80</span>&gt;<br>    DocumentRoot <span class="hljs-string">&quot;/web/bbts&quot;</span>      # 网站文件的目录<br>    ServerName bbts.wokegame.com  # 网站的网址<br>    &lt;Directory /web/bbts&gt;         # 目录访问权限<br>        Require all granted<br>        AllowOverride All<br>    &lt;/Directory&gt;<br>&lt;/VirtualHost&gt;<br></code></pre></td></tr></table></figure>

<p>完成配置后重启apache测试</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> /opt/lampp/lampp restartapache</span><br></code></pre></td></tr></table></figure>

<p>这样一个虚拟主机的站点就弄好了，为了wordpress能一路顺畅的安装，接下来先做好一些准备工作</p>
<h2 id="MySQL配置"><a href="#MySQL配置" class="headerlink" title="MySQL配置"></a>MySQL配置</h2><p>我们需要为wordpress创建一个数据库与数据库用户，开始吧</p>
<h3 id="创建数据库"><a href="#创建数据库" class="headerlink" title="创建数据库"></a>创建数据库</h3><p>首先登陆数据库，XAMPP的MYSQL程序在<code>/opt/lampp/bin/mysql</code></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> mysql -u root -p    // 登陆MYSQL</span><br></code></pre></td></tr></table></figure>

<p>登陆后创建数据库命令：</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql">MYSQL&gt; CREATE DATABASE bbts;<br></code></pre></td></tr></table></figure>

<h3 id="修改root密码"><a href="#修改root密码" class="headerlink" title="修改root密码"></a>修改root密码</h3><p>root默认没有密码，设置一个密码。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql">MYSQL&gt; UPDATE user SET password=password(&#x27;&lt;新密码&gt;&#x27;) WHERE user=&#x27;root&#x27;;<br></code></pre></td></tr></table></figure>

<h3 id="创建用户并授权"><a href="#创建用户并授权" class="headerlink" title="创建用户并授权"></a>创建用户并授权</h3><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql">MYSQL&gt; CREATE USER &#x27;&lt;用户名&gt;&#x27;@&#x27;&lt;主机&gt;&#x27; IDENTIFIED BY &#x27;&lt;密码&gt;&#x27;;<br></code></pre></td></tr></table></figure>

<ul>
<li>&lt;用户名&gt;: 用户名，随喜好</li>
<li>&lt;主机&gt;: 允许在何处登陆，’%’为任何地方都可登陆</li>
<li>&lt;密码&gt;: ………</li>
</ul>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql">MYSQL&gt; GRANT &lt;操作权限&gt; ON &lt;数据库名&gt;.&lt;表名&gt; TO &#x27;&lt;用户名&gt;&#x27;@&#x27;&lt;主机&gt;&#x27;;<br></code></pre></td></tr></table></figure>

<ul>
<li>&lt;操作权限&gt;: 设置可以用什么命令，这里我填ALL privileges</li>
<li>&lt;数据库名&gt;: 设置数据库，所有数据库都运行的话填*</li>
<li>&lt;表名&gt;: 设置可操作表，数据库下所有表允许填*</li>
</ul>
<h3 id="刷新权限"><a href="#刷新权限" class="headerlink" title="刷新权限"></a>刷新权限</h3><p>设置完权限后刷新一下比较保险</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql">MYSQL&gt; FLUSH PRIVILEGES;<br></code></pre></td></tr></table></figure>

<h3 id="查看权限"><a href="#查看权限" class="headerlink" title="查看权限"></a>查看权限</h3><p>各种设置完成后，查看权限使用的命令</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sql">MYSQL&gt; select * from mysql.columns_priv;<br>MYSQL&gt; SELECT user, host,select_priv, insert_priv, update_priv,delete_priv from mysql.user;<br></code></pre></td></tr></table></figure>


<h2 id="FTP服务器配置"><a href="#FTP服务器配置" class="headerlink" title="FTP服务器配置"></a>FTP服务器配置</h2><h3 id="创建FTP用户"><a href="#创建FTP用户" class="headerlink" title="创建FTP用户"></a>创建FTP用户</h3><p>创建一个用户组，方便划分FTP用户，名字可自定义</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> groupadd ftpusers</span><br></code></pre></td></tr></table></figure>

<p>创建FTP用户</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> useradd ftpbbts -d /web/bbts -s /sbin/nologin</span><br></code></pre></td></tr></table></figure>

<p>-d 选项为设置主目录，这里把他设置为网站目录，”-s /sbin/nologin” 选项为禁止登陆，ftpbbts为用户名，可更改。个人习惯前缀加上ftp</p>
<h3 id="修改目录权限"><a href="#修改目录权限" class="headerlink" title="修改目录权限"></a>修改目录权限</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> chown -R ftpbbts /web/bbts  // 更改目录所有者</span><br><span class="hljs-meta">#</span><span class="bash"> chmod 755 -R /web/bbts      // 更改目录权限</span><br></code></pre></td></tr></table></figure>

<h3 id="修改ProFTPD配置"><a href="#修改ProFTPD配置" class="headerlink" title="修改ProFTPD配置"></a>修改ProFTPD配置</h3><p>找到</p>
<figure class="highlight accesslog"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs accesslog">DefaultRoot /opt/lampp/htdocs<br></code></pre></td></tr></table></figure>

<p>这一行，修改为</p>
<figure class="highlight accesslog"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs accesslog">DefaultRoot ~<br></code></pre></td></tr></table></figure>

<p>之后重启FTP服务器或整个重启XAMPP，完成准备</p>
<h1 id="安装WordPress"><a href="#安装WordPress" class="headerlink" title="安装WordPress"></a>安装WordPress</h1><p>下载地址：<a target="_blank" rel="noopener" href="https://wordpress.org/download/">WordPress</a></p>
<p>下载完成后以各种方式自行上传至虚拟主机目录并解压</p>
<p>之后使用浏览器直接访问虚拟主机，填入刚才创建的数据库以及数据库账户</p>
<div id="paginator"></div></div><div id="post-footer"><hr><a href="/2019/03/11/linux%E8%87%AA%E5%8A%A8%E6%8C%82%E8%BD%BD/">← Prev linux自动挂载</a><hr></div><div id="bottom-btn"><a id="to-index" href="#post-index" title="index">≡</a><a id="to-top" href="#post-title" title="to top">∧</a></div><div id="Valine"></div><script>new Valine({
 el: '#Valine'
 , appId: 'w0GpBUKuLLybCyT9IuCKjvz5-9Nh9j0Va'
 , appKey: 'RHBH0vdwxr2ikIt32lBoqK69'
 , placeholder: '此条评论委托企鹅物流发送'
})</script></div></article><aside><div id="about"><a href="/" id="logo"><img src="https://ak.hypergryph.com/assets/index/images/ak/pc/faction/1.png" alt="Logo"></a><h1 id="Dr"><a href="/"> Dr.Chilono</a></h1><section id="total"><a id="total-archives" href="/archives"><span class="total-title">Archives Total:</span><span class="total-number">14</span></a><div id="total-tags"><span class="total-title">Tags:</span><span class="total-number">35</span></div><div id="total-categories"><span class="total-title">Categories:</span><span class="total-number">3</span></div></section></div><div id="aside-block"><h1>INDEX</h1><div id="post-index"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%BC%80%E5%A7%8B%E5%87%86%E5%A4%87"><span class="toc-number">1.</span> <span class="toc-text">开始准备</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#XAMPP"><span class="toc-number">2.</span> <span class="toc-text">XAMPP</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85xampp"><span class="toc-number">2.1.</span> <span class="toc-text">安装xampp</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#apache%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA"><span class="toc-number">2.2.</span> <span class="toc-text">apache虚拟主机</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#MySQL%E9%85%8D%E7%BD%AE"><span class="toc-number">2.3.</span> <span class="toc-text">MySQL配置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">2.3.1.</span> <span class="toc-text">创建数据库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9root%E5%AF%86%E7%A0%81"><span class="toc-number">2.3.2.</span> <span class="toc-text">修改root密码</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7%E5%B9%B6%E6%8E%88%E6%9D%83"><span class="toc-number">2.3.3.</span> <span class="toc-text">创建用户并授权</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%B7%E6%96%B0%E6%9D%83%E9%99%90"><span class="toc-number">2.3.4.</span> <span class="toc-text">刷新权限</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E6%9D%83%E9%99%90"><span class="toc-number">2.3.5.</span> <span class="toc-text">查看权限</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#FTP%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%85%8D%E7%BD%AE"><span class="toc-number">2.4.</span> <span class="toc-text">FTP服务器配置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BAFTP%E7%94%A8%E6%88%B7"><span class="toc-number">2.4.1.</span> <span class="toc-text">创建FTP用户</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E7%9B%AE%E5%BD%95%E6%9D%83%E9%99%90"><span class="toc-number">2.4.2.</span> <span class="toc-text">修改目录权限</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9ProFTPD%E9%85%8D%E7%BD%AE"><span class="toc-number">2.4.3.</span> <span class="toc-text">修改ProFTPD配置</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85WordPress"><span class="toc-number">3.</span> <span class="toc-text">安装WordPress</span></a></li></ol></div></div><footer><nobr><span class="text-title">©</span><span class="text-content">1970 to 2020</span></nobr><wbr><nobr><span class="text-title">ICP</span><span class="text-content">——备案号——</span></nobr><wbr><wbr><nobr>published with&nbsp;<a target="_blank" rel="noopener" href="http://hexo.io">Hexo&nbsp;</a></nobr><wbr><nobr>Theme&nbsp;<a target="_blank" rel="noopener" href="https://github.com/Yue-plus/hexo-theme-arknights">Arknight&nbsp;</a></nobr><wbr><nobr>by&nbsp;<a target="_blank" rel="noopener" href="https://github.com/Yue-plus">Yue_plus</a></nobr></footer></aside></main><script src="/js/arknights.js"></script><script src="https://cdn.bootcdn.net/ajax/libs/highlight.js/10.1.2/highlight.min.js"></script></body></html>